package com.example.controller;

import com.example.domain.User;
import com.example.common.Rt;
import com.example.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zhangming
 * @Date 2021/10/8 14:59
 * @Version 1.0
 * @Desc: TODO
 */
@RequestMapping("/user")
@RestController
public class UserController {

	@Autowired
	private UserMapper userMapper;

	@GetMapping("/{id}")
	public Rt<User> detail(@PathVariable("id") Integer id) {

		//验证hystrix超时熔断机制，如果服务宕机直接判定熔断
		/*try {
			Thread.sleep(20000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}*/

		User user = userMapper.getById(id);
		return Rt.success(user);
	}

}
